package ar.edu.unq.wannaplay.utils;

public class CalendarMatrix extends Matrix {

    public CalendarMatrix(final int rows, final int cols, final Info info) {
        super(rows, cols, info);
    }

    public void putDay(final int iCoor, final int jCoor, final int day) {
        ((DayInfo) this.getBaseMatrix().get(iCoor).get(jCoor)).setDay(day);
    }

    public Pair<Integer, Integer> getDayCoordinates(final int day) {
        Pair<Integer, Integer> pair = null;
        for (int i = 0; i < this.getWidth(); i++) {
            if (pair == null) {
                for (int j = 0; j < this.getHeight(); j++) {
                    if (((DayInfo) this.getBaseMatrix().get(i).get(j)).getDay() == day) {
                        pair = this.createPair(i, j);
                        break;
                    }
                }
            } else {
                break;
            }
        }
        return pair;
    }

    private Pair<Integer, Integer> createPair(final int iCoor, final int jCoor) {
        return new Pair<Integer, Integer>(iCoor, jCoor);
    }
}
